function replaceAll(param){
	while(param.indexOf("|") > -1){
		param = param.replace('|','"');
	}
	return param;
}
//退出登录
var logout =  {
		login_out : function() {
			var  suid = sessionStorage.getItem("suid_name");
			$.ajax({
				type : "GET",
				url : "http://127.0.0.1:8080/yl-websocket/transmit?param='m=logout,suid=" + suid +"&address=http://103.37.166.4:7777/StateGrid/ua.do",
				async: false,
				scriptCharset: 'utf-8', 
				success : function(param) {
					if(JSON.parse(param).stat == "1"){
						logout.clean_trace();
						location.href='login.html';
					}
				},
				error: function(){
				}
				
			});
		},
		clean_trace : function(){
			sessionStorage.clear();
		},
		verify : function(){
			if(sessionStorage.getItem("suid") == null){
				location.href='login.html';
			}
		}
	}
//2017-03-07T01:56
function format(datetime){
	datetime = datetime.replace("-","");
	datetime = datetime.replace("-","");
	datetime = datetime.replace("T","");
	datetime = datetime.replace(":","");
	datetime = datetime.replace(":","");
	return datetime;
}

function isNull(str){
	if( str == null || str.replace(/(^\s*)|(\s*$)/g,"") == ""){
		return false;
	}else
		return true;
}
$(function() {
	$("#logout_obt").click(function() {
		logout.login_out();
	});
	logout.verify();
	//获取登录人名立即执行
	(function(){
		if(sessionStorage.getItem("suid") != null){
			var userJson = JSON.parse(sessionStorage.getItem("suid")).data;
			sessionStorage.setItem("roleName", userJson.roleName);
			sessionStorage.setItem("name",userJson.su_name );
			$("#login_name").html(userJson.su_name);
			$("#roleName").html(userJson.roleName);
		}
	})();
});